<?php 
/*
成员类
	列表
	详情
		基本资料
		DKP
		Loot
		事件
		Armory
	统计
		职业比例
		活跃度
	管理
		添加
		批量添加
		删除
		修改基本资料
	*/
class Player {
	public $id;
	public $playername, $level, $race, $playerclass, $jointime, $activist, $note, $looted, $raidnum, $state, $lastraid, $playerlog ;

	public $error_info;


	private function viewPlayerList($sort) {
		return;
	}


	//设置要操作的成员
	public function setPlayer($id) {
		$sql="select * from player where id=".$id;
		if ($result = mysql_query($sql)) {
			$row = mysql_fetch_array($result);
			 $this->id = $id;
			$this->playername = $row['player_name'];
			$this->level = $row['player_level'];
			$this->race = $row['player_race'];
			$this->playerclass = $row['player_class'];
			$this->jointime = $row['player_jointime'];
			$this->activist = $row['player_activist'];
			$this->note = $row['player_note'];
			$this->looted = $row['player_looted'];
			$this->raidnum = $row['player_raidnum'];
			$this->state = $row['player_state'];
			$this->lastraid = $row['player_lastraid'];
			$this->playerlog = $row['player_log'];

			$this->playerisset = true;
			return true;
		}else{
			$this->playerisset = false;
			return false;
		}
	}

	//显示Armory信息
	public function viewArmory() {
		if (!$this->playerisset) { $this->error_info .= "错误,player未指定"; return false;}
		$html .= "<div class='ArmoryCharFrame outframe'>";
		$html .= "<a class='face' href='http://cn.wowarmory.com/character-sheet.xml?r=".rawurlencode($GuildServer)."&n=".rawurlencode($player_name)."'><img src='images/icon/charnoface.gif' alt='' /></a>";
		$html .= "<dl>";
		$html .= "<dt>".$result['player_name']." &lt;<span name='GuildName'>GuildName</span>&gt;</dt>";
		$html .= "<dd><span class='level'>??</span> <span class='xclass'>unknow</span> <span class='talent'>?/?/?</span> <span class='skill1'>Skill1</span> <span class='skill2'>Skill2</span></dd>";
		$html .= "<dd>HP<span class='hp'>-----</span> MP<span class='mp'>-----</span></dd>";
		$html .= "<dd class='equip'>";
		$html .= "<img name='eq1' src='images/icon/empty.png' alt='' /><img name='eq2' src='images/icon/empty.png' alt='' /><img name='eq3' src='images/icon/empty.png' alt='' /><img name='eq4' src='images/icon/empty.png' alt='' /><img name='eq5' src='images/icon/empty.png' alt='' /><img name='eq6' src='images/icon/empty.png' alt='' /><img name='eq7' src='images/icon/empty.png' alt='' /><img name='eq8' src='images/icon/empty.png' alt='' /><img name='eq9' src='images/icon/empty.png' alt='' /><img name='eq10' src='images/icon/empty.png' alt='' /><img name='eq11' src='images/icon/empty.png' alt='' /><img name='eq12' src='images/icon/empty.png' alt='' /><img name='eq13' src='images/icon/empty.png' alt='' /><img name='eq14' src='images/icon/empty.png' alt='' /><img name='eq15' src='images/icon/empty.png' alt='' /><img name='eq16' src='images/icon/empty.png' alt='' /><img name='eq17' src='images/icon/empty.png' alt='' /><img name='eq18' src='images/icon/empty.png' alt='' />";
		$html .= "</dd></dl></div>";
		return $html;
	}





	//显示player基本信息
	public function viewBaseInfo() {
		if (!$this->playerisset) { $this->error_info .= "错误,player未指定"; return false;}
		$html .= "<table class='BaseInfo outframe'>";
		$html .= "<tr><th colspan='3'><div class='title' name='".$this->playername."'>".propic($result["player_class"]).$this->playername." [".$this->state."]</div><div class='filter'>".$this->getPlayerSelectFormByClass()."</div></th></tr>";
		$html .= "<tr><td>职业:".$this->playerclass."</td><td>职位:X</td><td>最近活动:".time_type($this->lastraid,3)."</td></tr>";
		$html .= "<tr class='b'><td>种族:".$this->race."</td><td>军衔:X</td><td>出场:".$this->raidnum."次</td></tr>";
		$html .= "</table>";
		return $html;
	}




	//显示玩家拾取的物品
	public function viewLooted() {
		if (!$this->playerisset) { $this->error_info .= "错误,player未指定"; return false;}
		$html .= "<table class='Looted outframe'>";
		$html .= "<tr><th><div class='title'><img src='images/icon/clock.jpg' >物品获得</div></th></tr>";
		$html .= "<tr><td>".$this->looted."</td></tr>";
		$html .= "</table>";
		return $html;
	}


	//显示调分事件
	public function viewEvents() {
		if (!$this->playerisset) { $this->error_info .= "错误,player未指定"; return false;}
		$sql="select * from raid_event where event_object='".$this->playername."' or event_object like '%|".$this->playername."|%' order by event_time desc";
		if ($result = mysql_query($sql)) {
			$html .= "<tr class='coltitle'><td>日期</td><td>DKP分类</td><td>事件</td><td>对象</td><td>分数</td></tr>";
			while ($row = mysql_fetch_array($result)) {
				$html .= "<tr class='".linec($i)."'><td>".time_type($row["event_time"],3)."</td><td>".getRaidClassText($row["raid_class"])."</td><td>".$row["event_class"]."</td><td>".$row["event_object2"]."</td><td>".$result["event_dkp"]."</td></tr>";
			}
		}else{
			$html .= "<tr><td colspan='5'>没有特殊事件</td></tr>";
		}
		$html = "<table class='outframe'><tr><th colspan='5'><div class='title'><img src='images/icon/clock.jpg' >调分事件</div></th></tr>".$html."</table>";
		if (isset($player_log)) {
		} 
		return $html;
	}

	//显示已归档的调分事件
	public function viewFreezEvents() {
		if (!$this->playerisset) { $this->error_info .= "错误,player未指定"; return false;}
		return "<table class='outframe'><tr><th>归档的调分事件</th></tr><tr><td><ul class='interlace'>".$this->playerlog."</ul></td></tr></table>";
	}


	//成员添加表单
	public function viewPlayerAdd() {
		$html .= "<form action='?action=add' method='post'>";
		$html .= "<table class='outframe interlace'>";
		$html .= "<tr><th colspan='2'>添加新会员</th></tr>";
		$html .= "<tr><td>姓名</td><td><input type='input' name='player_name' value=''/>检查是否已存在</td></tr>";
		$html .= "<tr><td>种族职业</td><td>".raceselect("player_race","")." ".proselect("player_class","")."</td></tr>";
		$html .= "<tr><td>等级</td><td><input type='input' name='player_level' value='".$DefalutPlayerLevel."'/></td></tr>";
		$html .= "<tr><td>加入时间</td><td><input type='input' name='player_jointime'/> 留空则取当前日期</td></tr>";
		$html .= "<tr><td>职务</td><td><input type='input' name='player_guildlevel' value=''/></td></tr>";
		$html .= "<tr><td>技能A</td><td>".skillselect("player_skill_1","")."</td></tr>";
		$html .= "<tr><td>技能B</td><td>".skillselect("player_skill_2","")."</td></tr>";
		$html .= "<tr><td>备注</td><td><textarea name='player_note' rows='8' cols='50'></textarea></td></tr>";
		$html .= "<tr><td></td><td><input type='submit' value='确定'/></td></tr>";
		$html .= "</table></form>";
		return $html;
	}


	//显示成员编辑表单
	function viewPlayerEdit($id) {
		if ($_SESSION["level"]>1) {
			showerror("权限不足");
			return $function_ret;
		} 
		if (!is_numeric(${"id"})) {
			return $function_ret;
		} 
		$sql="select * from player where id=".${"id"};
		$result = mysql_query($sql);
		if ($result->eof || $result->bof) {
			print "错误";
			return $function_ret;
		} 

		$html .= "<form action='?action=edit' method='post'>";
		$html .= "<table class='outframe interlace'>";
		$html .= "<tr><th colspan='2'>会员资料编辑</th></tr>";
		$html .= "<tr><td>姓名</td><td><input type='input' name='player_name' value='".$result["player_name"]."'/></td></tr>";
		$html .= "<tr><td>职业</td><td>".proselect("player_class",$result["player_class"])."</td></tr>";
		$html .= "<tr><td>种族</td><td>".raceselect("player_race",$result["player_race"])."</td></tr>";
		$html .= "<tr><td>等级</td><td><input type='input' name='player_level' value='".$result["player_level"]."'/></td></tr>";
		$html .= "<tr><td>加入时间</td><td><input type='input' name='player_jointime' value='".$result["player_jointime"]."'/> 留空则取当前日期</td></tr>";
		$html .= "<tr><td>组织职务</td><td><input type='input' name='player_guildlevel' value='".$result["player_guildlevel"]."'/></td></tr>";
		$html .= "<tr><td>商业技能</td><td>".skillselect("player_skill_1",$result["player_skill_1"]).skillselect("player_skill_2",$result["player_skill_2"])."</td></tr>";
		$html .= "<tr><td></td><td></td></tr>";
		$html .= "<tr><td>获取装备</td><td><textarea name='player_looted' rows='3' cols='50'>".$result["player_looted"]."</textarea>只读</td></tr>";
		$html .= "<tr><td>参加次数</td><td><input type='input' name='player_raidnum' value='".$result["player_raidnum"]."'/></td></tr>";
		$html .= "<tr><td>活跃度</td><td><input type='input' name='player_activist' value='".$result["player_activist"]."'/></td></tr>";
		$html .= "<tr><td>状态</td><td>".playerstatusselect("player_state",$result["player_state"])."</td></tr>";
		$html .= "<tr><td>备注</td><td><textarea name='player_note' rows='5' cols='50'>".$result["player_note"]."</textarea></td></tr>";
		$html .= "<tr><td></td><td><input type='submit' value='确定'/> <input type='hidden' name='postid' value='".${"id"}."' /></td></tr>";
		$html .= "</table></form>";
		return $html;
	} 









	//显示一个同职业的下拉选择框
	private function getPlayerSelectFormByClass($class) {
		if (!$class) {$class = $this->playerclass;}
		$html .= "<form method='post' action=''><select name='filter' onChange='javascript:submit();'>";
		$html .= "<option value=''>--".$class."--</option>";
		$sql="select * from player where player_class='".$class."' order by player_name";
		if ($result=mysql_query($sql)) {
			while ($row = mysql_fetch_array($result)) {
				$html .= "<option value='".$row["id"]."'>".$row["player_name"]."</option>";
			}
		}else{
			$html .= "<option value='0'>没有此类成员</option>";
		} 
		$html .= "</select></form>";
		return $html;
	}
















} // class End.




?>
